<?php
/**
* 取得诚信会员信息
* @param num		取得诚信会员的数量
* @return String
*/
function getRMInfo($num)
{
	global $db;
	//$sql=" select mem_name,mem_id from member_merchant where mem_isreputation=1 order by mem_reputation desc limit 0,$num";
	$sql=" select b.mem_id mem_id,b.companyname companyname,a.Reputation from mem_cnt a,member_merchant b where a.mem_id=b.mem_id and b.mem_typeid<>'2' order by a.Reputation desc limit 0,$num";
	//echo $sql;
	$rs=$db->Execute($sql);
	$i=0;
	while($rs && $row=$rs->FetchRow())
	{
		$ss[$i]=$row;
		$ss[$i]['url']=WEBDOMAIN.'/company/index.php?id='.$row['mem_id'];
		$i++;
	}
	return $ss;
}

/** createMemOther	用户的附加参数创建
* @param mem_id		会员id
* @return Void
*/
function createMemOther($mem_id)
{
	if($mem_id<=0)
	{
		return false;
	}
	$t=new Tbl_Act('member_merchant','mem_id');
	$t->mem_id=$mem_id;
	$t->GetOne();
	if(empty($t->mem_name))
	{
		return false;
	}
	
	//资质认证
	$mem_check=new Tbl_Act('mem_check','mem_id');
	$mem_check->mem_id=$mem_id;
	$mem_check->mem_name=$t->mem_name;
	$mem_check_cnt=$mem_check->RsCount(array('mem_id,='));	//数量
	if($mem_check_cnt==0)
	{
		$mem_check->Insert();
	}
	//数字统计
	$mem_cnt=new Tbl_Act('mem_cnt','mem_id');
	$mem_cnt->mem_id=$mem_id;
	$mem_cnt->mem_name=$t->mem_name;
	$mem_cnt_cnt=$mem_cnt->RsCount(array('mem_id,='));	//数量
	if($mem_cnt_cnt==0)
	{
		$mem_cnt->Insert();
	}
	//用户习惯
	$mem_habits=new Tbl_Act('mem_habits','mem_id');
	$mem_habits->mem_id=$mem_id;
	$mem_habits->mem_name=$t->mem_name;
	$mem_habits_cnt=$mem_habits->RsCount(array('mem_id,='));	//数量
	if($mem_habits_cnt==0)
	{
		$mem_habits->Insert();
	}
	return $t->mem_name;
}

/** getCheckImg 资质认证图表显示
* @param mem_id
* @return String
*/
function getCheckImg($mem_id)
{
	$t=new Tbl_Act('mem_check','mem_id');
	$t->mem_id=$mem_id;
	$t->GetOne();
	$checkparam=array('shenfen|身份证','yingyezhizhao|营业执照','jiashi|驾驶证','xingshi|行驶证','yunying|运营证');	//设置需要显示的项目
	$ss='';
	foreach($checkparam as $key => $value)
	{
		$aryvalue=explode('|',$value);
		if($t->$aryvalue[0]==1)
		{
			$img_name=WEBDOMAIN.'/images/img_check/IMG_'.$aryvalue[0].'.gif';
			$ss.='<span class="p7"><img src="'.$img_name.'" border="0" title="'.$aryvalue[1].'"></span>';
		}
	}
	return $ss;
}

/** getMemCntByMemId 根据会员id取得统计参数
* @param mem_id		会员id
* @param p			参数名称
* @return Integer
*/
function getMemCntByMemId($mem_id,$p)
{
	if($mem_id<=0)
	{
		return false;
	}
	global $db;
	$sql="select $p from mem_cnt where mem_id='$mem_id'";
	$rs=$db->Execute($sql);
	if($rs && $row=$rs->FetchRow())
	{
		return $row[$p];
	}
	else
	{
		return 0;
	}
}

/** getMemCntByMemId 根据会员id取得统计参数
* @param mem_id		会员id
* @param p			参数名称
* @return Integer
*/
function getMemInfoByMemId($mem_id,$p)
{
	if($mem_id<=0)
	{
		return false;
	}
	global $db;
	$sql="select $p from member_merchant where mem_id='$mem_id'";
	$rs=$db->Execute($sql);
	if($rs && $row=$rs->FetchRow())
	{
		return $row[$p];
	}
	else
	{
		return 0;
	}
}

/** 获取用户注册类别
* @return Array
*/
function getMemRegType()
{
	global $db;
	$sql="select * from mem_type order by px desc";
	$rs=$db->Execute($sql);
	$ss='';
	$i=0;
	while($rs && $row=$rs->FetchRow())
	{
		$ss[$i]['id']=$row['id'];
		$ss[$i]['typename']=$row['typename'];
		$i++;
	}
	return $ss;
}

/** getMemRegTypeById 根据id获取会员注册类型
* @param id
* @return String
*/
function getMemRegTypeById($id)
{
	$t=new Tbl_Act('mem_type','id');
	$t->id=$id;
	$ss=$t->GetVal('typename');
	return $ss;
}
?>